package com.JZ.QM.controller;

import com.JZ.QM.common.entity.CombinationShareEntity;
import com.JZ.QM.common.entity.NewCombinationShareEntity;
import com.JZ.QM.common.utils.CommonResult;
import com.JZ.QM.service.NewCombinationShareService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * @author lyp
 * @email lyp@gmail.com
 * @date 2020/7/13 13:30
 */
@RefreshScope
@RestController
@Slf4j
@RequestMapping("/newCombinationShare")
public class NewCombinationShareController {

    @Resource
    NewCombinationShareService newCombinationShareService;
    /**
     * 通过组合id获取成分产品列表
     * @param comBaseId
     * @return
     */
    @RequestMapping("/getCombinationShareList")
    public CommonResult getCombinationShareList(Long comBaseId){

        //股票成分产品列表
        ArrayList<NewCombinationShareEntity> stockList = new ArrayList<>();
        //基金成分产品列表
        ArrayList<NewCombinationShareEntity> fundList = new ArrayList<>();

        stockList = newCombinationShareService.getCombinationShareList(comBaseId,1);

        fundList = newCombinationShareService.getCombinationShareList(comBaseId,0);

        return CommonResult.success()
                .put("stockList",stockList)
                .put("fundList",fundList);
    }
}
